package a10threadsafe2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86131
 * Date: 2024-04-17
 * Time: 11:23
 */
public class ThreadDemo {
    //技巧: 首先不要写同步方法,先写同步代码块,再把同步代码块里面的代码抽取成方法
    public static void main(String[] args) {
        MyRunnanble mr = new MyRunnanble();

        Thread t1 = new Thread(mr);
        Thread t2 = new Thread(mr);
        Thread t3 = new Thread(mr);

        //起名字
        t1.setName("窗口1");
        t2.setName("窗口2");
        t3.setName("窗口3");

        t1.start();
        t2.start();
        t3.start();
    }
}
